package br.com.colegio.dao.storage;

import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

import br.com.colegio.dao.FinanceiroLancamentoDAO;
import br.com.colegio.util.UtilData;

public class FinanceiroLancamentoData {/*
	private static FinanceiroLancamentoData instance;
	private Map<Long,FinanceiroLancamento> data = new TreeMap<Long,FinanceiroLancamento>();
	private Map<Long,Map<String,Set<FinanceiroLancamento>>> dataConta = new TreeMap<Long,Map<String,Set<FinanceiroLancamento>>>();

	private FinanceiroLancamentoData(){}

	public static FinanceiroLancamentoData getInstance(){
		if(instance == null)
			instance = new FinanceiroLancamentoData();

		return instance;
	}

	private Map<Long,FinanceiroLancamento> getData(){
		if(data.size() == 0){
			Collection<Object> r = FinanceiroLancamentoDAO.list();
			if(r != null)
				for(Object o : r){
					FinanceiroLancamento a = (FinanceiroLancamento)o;
					data.put(a.getKey().getId(),a);

					if(!dataConta.containsKey(a.getContaKey()))
						dataConta.put(a.getContaKey(),new HashMap<String,Set<FinanceiroLancamento>>());

					if(!dataConta.get(a.getContaKey()).containsKey(UtilData.format(a.getData(),"yyyyMM")))
						dataConta.get(a.getContaKey()).put(
								UtilData.format(a.getData(),"yyyyMM"),new HashSet<FinanceiroLancamento>());

					dataConta.get(a.getContaKey()).get(UtilData.format(a.getData(),"yyyyMM")).add(a);
				}
		}
		return data;
	}

	public Map<String,Set<FinanceiroLancamento>> getItens(long conta){
		getData();

		if(dataConta.containsKey(conta))
			return dataConta.get(conta);

		return null;
	}

	public FinanceiroLancamento getItem(Long id){
		return getData().get(id);
	}

	public Collection<FinanceiroLancamento> getItens(){
		return getData().values();
	}*/
}